<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php include('menu.php'); ?>
<script>
function setFocus(){
document.formedit.par.focus();
}
</script>
</head>
<body onload="setFocus()">
<?php
include("../connect/connect.php");

//แก้ไข
if($_GET["action"]=="update") {

	if($_POST['par'] != "")
		{
			$Query = "UPDATE stock_bar SET stock_bar_par = '".$_POST["par"]."' WHERE stock_bar_id = '".$_POST["stock_bar_id"]."' ";
			$objQuery = mysql_query($Query);
			
			echo "<script type=\"text/javascript\"> window.location=\"stock_bar_manage.php\"</script>";
			exit();
		}
}

$Query = "SELECT product.prod_name as prod_name,stock_bar.stock_bar_par as stock_bar_par FROM product,stock_bar WHERE product.prod_id = stock_bar.prod_id and stock_bar.stock_bar_id = '".$_GET["id"]."'";
$objQuery = mysql_query($Query) or die ("Error Query [".$Query."]");
$row = mysql_fetch_array($objQuery);
?>
<form action="?action=update" name="formedit" method="post" id="formedit">
<div class="box">
  <div class="left"></div>
  <div class="right"></div>
    <div class="heading"><h1>แก้ไขข้อมูลสินค้าในสต็อกบาร์</h1>
    <div class="buttons"><a onclick="formedit.submit();" class="button"><span>บันทึก</span></a><a onclick="location = 'product_manage.php';" class="button"><span>ยกเลิก</span></a></div></div>
  <div class="content">
    <table class="form">
      <tr>
        <td>ชื่อสินค้า : </td>
        <td><input name="name" type="text" id="name" value="<?php echo $row["prod_name"];?>" readonly="readonly" /><input name="stock_bar_id" type="hidden"  value="<?php echo $_GET["id"];?>"  /></td>
      </tr>
      <tr>
        <td>จุดสั่งซื้อ : </td>
        <td><input name="par" type="text" id="par" value="<?php echo $row["stock_bar_par"];?>" onkeydown="if(event.keyCode==13){formedit.submit();}" /></td>
      </tr>
    </table>
  </div>
</div>
</form>
</body>
<?php mysql_close(); ?>
</html>
